package com.bocai.controller;

import com.bocai.bean.RuleInfo;
import com.bocai.service.IRuleTypeService;
import com.bocai.utils.CodeEnum;
import com.bocai.utils.ObjUtils;
import com.bocai.utils.ResponseData;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RuleTypeController {

    @Autowired
    private IRuleTypeService ruleTypeService;

    @ApiOperation(value = "获取玩法信息", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "selectedId", dataType = "int", required = true, value = "选项id", defaultValue = ""),
            @ApiImplicitParam(paramType = "query", name = "ruleTypeId", dataType = "int", required = true, value = "玩法id", defaultValue = ""),
    })
    @RequestMapping(value = "getRuleTypeDetail", method = RequestMethod.GET)
    @ResponseBody
    public ResponseData getRuleTypeDetail(Integer selectedId,Integer ruleTypeId){

        ResponseData data = new ResponseData();
        CodeEnum codeEnum = ObjUtils.validateParams(new Object[]{selectedId,ruleTypeId});
        if (ObjUtils.isNotEmpty(codeEnum)){
            data.setCodeEnum(CodeEnum.CODE_90002);
            return data;
        }

        data.setResults(ruleTypeService.selectRuleInfo(ruleTypeId,selectedId));
        data.setCodeEnum(CodeEnum.SUCCESS);

        return data;
    }
}
